﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DrugStock.aspx.cs" Inherits="Physio_Clinic.WebForm2" %>
<%@ Register assembly="Devart.Data.Linq.Web, Version=3.1.34.0, Culture=neutral, PublicKeyToken=09af7300eec23701" namespace="Devart.Data.Linq.Web" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% if (currentUser != null && currentUser.Username == "admin")
       {   
      %>
    <asp:Panel ID="Panel1" runat="server">
    <br />
    <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Large" 
        ForeColor="#99CCFF" Text="คลังยา"></asp:Label>
    <br />
    <br />
    <asp:Button ID="Button1" runat="server" onclick="Button2_Click" Text="เพิ่ม" />
    <asp:Button ID="Button2" runat="server" Enabled="False" onclick="Button3_Click" 
        Text="เเก้ไข" />
    <asp:Button ID="Button3" runat="server" Enabled="False" onclick="Button1_Click" 
        Text="ลบ" />
    <asp:GridView ID="GridView1" runat="server" 
        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" 
        CellSpacing="1" DataSourceID="DbLinqDataSource" GridLines="None" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        ShowHeaderWhenEmpty="True">
        <Columns>
            <asp:CommandField SelectText="เลือก" ShowSelectButton="True" 
                HeaderText="เลือก" />
            <asp:BoundField DataField="DrugId" HeaderText="เลขที่" ReadOnly="True" 
                SortExpression="DrugId" />
            <asp:BoundField DataField="DrugCode" HeaderText="รหัสยา (บาร์โค้ด)" 
                ReadOnly="True" SortExpression="DrugCode" />
            <asp:BoundField DataField="DrugName" HeaderText="ชื่อยา" ReadOnly="True" 
                SortExpression="DrugName" >
            <HeaderStyle Width="150px" />
            </asp:BoundField>
            <asp:BoundField DataField="DrugDetail" HeaderText="รายละเอียด" ReadOnly="True" 
                SortExpression="DrugDetail" >
            <HeaderStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField DataField="DrugPrice" HeaderText="ราคาต่อหน่วย" ReadOnly="True" 
                SortExpression="DrugPrice" />
            <asp:BoundField DataField="Amount" HeaderText="จำนวนที่เหลือ" ReadOnly="True" 
                SortExpression="Amount" />
        </Columns>
        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#594B9C" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#33276A" />
    </asp:GridView>
</asp:Panel>
<cc1:DbLinqDataSource ID="DbLinqDataSource" runat="server" 
    ContextTypeName="Physio10Context.Physio10DataContext" EntityTypeName="" 
    onselected="DbLinqDataSource_Selected" 
    Select="new (DrugCode, DrugPrice, DrugId, DrugName, Amount, DrugDetail)" 
    TableName="Drugs" Where="IsDrug == @IsDrug">
    <WhereParameters>
        <asp:Parameter DefaultValue="true" Name="IsDrug" Type="Boolean" />
    </WhereParameters>
</cc1:DbLinqDataSource>

    <% }
       else
       { %><asp:Label ID="ErrorText" runat="server" 
    Text="สิทธิหน้านี้สำหรับ ผู้ดูเเลระบบเท่านั้น " ForeColor="Red" 
        style="text-align: center"></asp:Label><asp:HyperLink ID="HyperLink1" 
    runat="server" NavigateUrl="http://physio10.com/" > click</asp:HyperLink><% } %>

</asp:Content>
